{include file="public/head" /}
<style>h1{text-align: center;margin-bottom: 20px}</style>
</head>
<body>
<div class="layui-row" style="margin-top: 30%">
    <div class="layui-col-xs12">
        <h1>图书馆用户登录</h1>
    </div>
</div>
<div class="layui-row">
    <div class="layui-col-xs11">
        <form class="layui-form" action="">
            <div class="layui-form-item">
                <label class="layui-form-label">用户名</label>
                <div class="layui-input-block">
                    <input type="text" name="username" lay-verify="required" autocomplete="off" placeholder="请输入用户名"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">密码</label>
                <div class="layui-input-block">
                    <input type="password" name="password" lay-verify="required" placeholder="请输入密码" autocomplete="off"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item" style="text-align: center">
                <a class="layui-btn" lay-submit="" lay-filter="login">登录</a>
            </div>
        </form>
    </div>
</div>
<script>
    layui.use('form', function () {
        var form = layui.form,layer = layui.layer;
        //表单提交
        form.on('submit(login)', function (data) {
            $.post("{:url('user/Login/doLogin')}",{data:data.field},function(res){
                if(res.code==0){
                    layer.msg(res.msg, {time: 2000, icon:5});
                }else{
                    layer.msg(res.msg, {time: 1500, icon:6});
                    setTimeout(function () {
                        window.location.href = "{:url('user/Index/index')}";
                    },1500)
                }
            },"json");
        });
    });
</script>
</body>
</html>